package cn.wolfcode.p2p.business.service;

import cn.wolfcode.p2p.business.domain.ExpAccount;
import lombok.Getter;
import org.apache.commons.lang3.time.DateUtils;

import java.util.Date;

public interface IExpAccountService {
    void update(ExpAccount expaccount);

    void save(ExpAccount expaccount);

    ExpAccount getExpAccount(Long id);



    @Getter
    class LastTime{
        private int amount;
        private LastTimeUnit unit;

        public LastTime(int amount, LastTimeUnit unit) {
            this.amount = amount;
            this.unit = unit;
        }
        //返回截止日期
        public Date getReturnDate(Date date){
            switch (this.unit){
                case Days : return DateUtils.addDays(date,amount);
                case Month : return DateUtils.addMonths(date,amount);
                case Year : return DateUtils.addYears(date,amount);
            }
            return date;
        }
    }

    enum LastTimeUnit{
        Days,Month,Year;
    }
}
